<?php


namespace App\HttpController\Admin;


use App\Common\Exception\HttpParamException;
use App\Common\Http\Code;
use App\Common\Languages\Dictionary;

/**
 * Class Sysinfo
 * @property \App\Model\Sysinfo $Model
 * @package App\HttpController\Admin
 */
class Sysinfo extends Auth
{
    protected function _search()
    {
        $where = [];
        if (isset($this->get['status']) && $this->get['status'] !== '')
        {
            $where['status'] = $this->get['status'];
        }
        foreach (['varname', 'remark'] as $col)
        {
            if (!empty($this->get[$col]))
            {
                $where[$col] = ["%{$this->get[$col]}%", 'like'];
            }
        }
        return $where;
    }

    protected function _writeBefore()
    {
        $post = $this->post;
        if (empty($post['varname']) || empty($post['value']) || !isset($post['type']))
        {
            return $this->error(Code::ERROR);
        }
    }

    /*protected function _afterIndex($items)
    {
        foreach ($items as &$value)
        {
            $value = $value->toArray();

            if ($value['type'] == $this->Model::TYPE_ARRAY)
            {
                $return = $this->Model->toArraybyEval($value['value'], true);
                if ($return !== false) {
                    $value['value'] = $return;
                }
            }
        }
        return $items;
    }*/
}
